<template>
  <div class="tabcontrol">
  <div v-for="(item, index) in titles" :key="index" class="tab-control-item" :class="{active: index===currentIndex}" @click="itemClick(index)">
      <span>{{item}}</span>
  </div>
  </div>
</template>

<script>
export default {
name:"tabcontrol",
props:{
    titles:{
        type:Array,
        default(){
            return [];
        }
    }
},
data() {
    return {
        currentIndex:0,
    }
},
methods: {
    itemClick(index){
    this.currentIndex=index;
    this.$emit("tabClick",index)
    }
},
}
</script>

<style>
.tabcontrol{
    display: flex;
    justify-content: space-between;
}
.tab-control-item{
  flex: 1;
}
.active span {
    border-bottom: 5px solid red;
    padding-bottom: 5px;
    color: red;
}
</style>